package com.bocai.dahuatech.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bocai.dahuatech.Bean.PointListBean;
import com.bocai.dahuatech.R;

import java.util.List;

public class MyPointAdapter extends BaseAdapter{

    private Context context;
    List<PointListBean.ContentEntity> datas;
    public MyPointAdapter(Context context, List<PointListBean.ContentEntity> datas) {
        this.context = context;
        this.datas=datas;
    }

    public void addDatas(List<PointListBean.ContentEntity> list){
        datas.addAll(list);
        this.notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
    if (convertView==null){
        viewHolder=new ViewHolder();
        LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
        convertView = mInflater.inflate(R.layout.my_point_item, parent, false);
        viewHolder.tvTime= (TextView) convertView.findViewById(R.id.tv_pointlist_time);
        viewHolder.tvNumber= (TextView) convertView.findViewById(R.id.tv_pointlist_number);
        viewHolder. tvCount= (TextView) convertView.findViewById(R.id.tv_pointlist_count);
        viewHolder.tvState= (TextView) convertView.findViewById(R.id.tv_pointlist_state);
        convertView.setTag(viewHolder);
    }else{
        viewHolder= (ViewHolder) convertView.getTag();
    }

        viewHolder.tvTime.setText(datas.get(position).getFDate());
        viewHolder.tvNumber.setText(datas.get(position).getFBillNo());
        viewHolder.tvCount.setText(context.getResources().getString(R.string.add)+datas.get(position).getFCoin());
        viewHolder.tvState.setText(datas.get(position).getFStatus());

        return convertView;
    }


    public class ViewHolder {

        TextView tvTime,tvNumber,tvCount,tvState;

        }


}
